package com.diudiutechnology.www.yadiudiu.yadiudiu.singlecall.MyActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.diudiutechnology.www.yadiudiu.yadiudiu.model.BuyACarFragmentModel;
import com.diudiutechnology.www.yadiudiu.R;
import com.diudiutechnology.www.yadiudiu.yadiudiu.singlecall.MyAdapter.CleaningActivityAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/8/23.
 * 蔬果
 */

public class FruitsAndVegetablesActivity extends Activity implements View.OnClickListener {
    @Bind(R.id.retur)//返回
    LinearLayout retur;

    Context context;
    @Bind(R.id.listview)
    ListView listview;

    @Bind(R.id.search_ly)//搜索
            LinearLayout search_ly;

    private List<BuyACarFragmentModel> listModel;
    CleaningActivityAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fruits_and_vegetables);
        ButterKnife.bind(this);
        context = this;
        initView();
    }

    private void initView() {
        retur.setOnClickListener(this);
        search_ly.setOnClickListener(this);
       // adapter=new CleaningActivityAdapter(this);
        listview.setAdapter(adapter);
        initData();
        listview.setOnItemClickListener(clickListener);
    }
    private  void initData(){
        listModel=new ArrayList<>();
        BuyACarFragmentModel model=new BuyACarFragmentModel();
        model.setName("洁净干洗店");
        model.setLet("百年老店，品质服务，绝对正宗干洗，用心服务，给您完美体验。");

        model.setDistance("2.25");
        model.setDate("20");
        model.setPraise("200");
        listModel.add(model);
        model=new BuyACarFragmentModel();
        model.setName("伊耐净洗衣生活馆");
        model.setLet("优秀的服务，完善的设施，让您的爱衣变得亮丽如新。");

        model.setDistance("2.25");
        model.setDate("20");
        model.setPraise("200");
        listModel.add(model);
        model=new BuyACarFragmentModel();
        model.setName("玛丽阿姨美国健康洗衣");
        model.setLet("百年老店，品质服务，绝对正宗干洗，用心服务，给您完美体验。");

        model.setDistance("2.25");
        model.setDate("20");
        model.setPraise("200");
        listModel.add(model);
       // adapter.addItem(listModel);
    }
    AdapterView.OnItemClickListener clickListener=new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent intent=  new Intent(context,DetailsFruitsAndVegetablesActivity.class);
            intent.putExtra("pos","1");
            startActivity(intent);
            //startActivity(new Intent(context,DryCleaningShopDetailsActivity.class));

        }
    };
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.retur:
                finish();
                break;
            case R.id.search_ly:
                startActivity(new Intent(context, SearchActivity.class));
                break;
        }
    }
}

